// pages/home/index.js
import QQMapWX from "../../utils/qqmap-wx-jssdk";
import { fileList } from "../../utils/jiekou/remen";
import { fileList2 } from "../../utils/jiekou/shangying";
import { fileList3 } from "../../utils/jiekou/dev";


// var QQMapWX = require('xxx/qqmap-wx.js');


var qqmapsdk = new QQMapWX({
  key: 'FRCBZ-G6AWW-VTHR6-RIUXL-JUDQ5-5EFSP' // 必填
}); 

Page({

  /**
   * 页面的初始数据
   */
  data: {
    city:"",
    list:[],
    list2:[],
    list3:[],
    totalPage:1,
    limit:10,
    start:1,
    
    indicatorDots: true,
    margin:"0px",
    margin2:"0px",

    vertical: false,
 
    background: ['../../assets/images/home/banner1.jpg', '../../assets/images/home/banner2.jpg', '../../assets/images/home/banner3.jpg'],
  },


  bindButtonTap:function(){
    var that=this
    wx.chooseVideo({
      sourceType:['album','camera'],
      maxDuration:60,
      camera:['front','back'],
      succes:function(res){
        that.setData({
          src:res.tempFilePath
        })
      }
    })
  },


  // $(function(){
  //   $(image).error(function(){
  //   	console.log('加载不出图片时触发');
  //       $(this).attr("src","../../../Public/images/logo_2.png");
  //   })
  // }),
 





  init(){
    var _this = this;

    fileList({
      
    })
    .then(res =>{
      console.log(res)
      _this.setData({
        list:res.data.data.list,
        
                    })
    })

      },

      init2(){
        var _this = this;
    
        fileList2({
          
        })
        .then(res =>{
          console.log(res)
          _this.setData({
            list2:res.data.data.list,
        
                        })
        })
    
          },

          init3(){
            var _this = this;
        
            fileList3({
              
            })
            .then(res =>{
              console.log(res)
              _this.setData({
                list3:res.data.data,
            
                            })
            })
        
              },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   this.init()
   this.init2()
   this.init3()

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  dingwei(){
    var _this = this;
    wx.getLocation({
      success(res){
        console.log(res);
        qqmapsdk.reverseGeocoder({
          location: `${res.latitude},${res.longitude}`,
          success(result){
            console.log(result)
            _this.setData({
              city:result.result.ad_info.city
            })
          }
        })
        
      }
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.dingwei();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})